#ifndef ishader_h__
#define ishader_h__
#include <math/vector.h>
#include <math/matrix44.h>
#include <graphics/irenderer.h>

namespace gecko
{

// forward declare types
struct GeometryBatch;
class Colour;

// Interface to all shaders.
class IShader
{
public:
	// Bind a parameter name in the shader file to an indexed parameter
	virtual bool BindParameter(unsigned int parameter, const char* parameterName) = 0;

	// SetTechnique
	virtual void SetTechnique(const char* techName) = 0;
	
	// Set the shader as begin rendering
	virtual void Begin() = 0;
	
	// Finish the rendering of the shader
	virtual void End() = 0;
	
	// Begin a numbered pass (use GetNumPasses before this)
	virtual void BeginPass(unsigned int pass) = 0;
	
	// End the current rendering pass
	virtual void EndPass() = 0;
	
	// Commit changes to the shader
	virtual void Commit() = 0;

	// Set a matrix shader parameter
	virtual void SetMatrix(unsigned int parameter, const Matrix44& m) = 0;
	
	// Set a vector shader parameter
	virtual void SetVector(unsigned int parameter, const Vector3f& v) = 0;
	
	// Set a bool shader parameter
	virtual void SetBool(unsigned int parameter, bool b) = 0;

	// Set an int shader parameter
	virtual void SetInt(unsigned int parameter, int i) = 0;

	// Set a float shader parameter
	virtual void SetFloat(unsigned int parameter, float f) = 0;
	
	// Set a blend mode shader parameter
	virtual void SetBlendMode(unsigned int parameter, IRenderer::eBlendMode b) = 0;

	// Set a texture shader parameter
	//void SetTexture(unsigned int parameter, Texture* texture);
	
	// Set a colour shader parameter
	virtual void SetColour(unsigned int parameter, const Colour& colour) = 0;

	// GetRenderBatch
	GeometryBatch* GetRenderBatch();
	
	// SetRenderBatch
	void SetRenderBatch(GeometryBatch* batch);

	// Serialise the shader in from a file
	virtual bool Serialise(IRenderer* r, const char* filename) = 0;

	// Release the shader resources
	virtual void Destroy() = 0;

	// Get the number of passes defined in the shader
	unsigned int GetNumPasses();

protected:
	// do parameter index fixup
	virtual void PostSerialise() = 0;

protected:
	char m_FileName[32];
	unsigned int m_NumPasses;

private:
	GeometryBatch* m_GeometryBatch;
};

}// namespace gecko

#endif // ishader_h__